#pragma once

#include <string>
#include "Singleton.h"
#include "expire_def.h"
#include "1700_account.pb.h"


struct stAccount
{
	std::uint32_t uid;
	std::string uuid;
	std::string agency;
	std::string username;
	std::uint32_t agency_id;
};

class AccountMgr
{
public:
    AccountMgr();
    virtual ~AccountMgr();

public:
    static AccountMgr* Instance()
	{
		return CSingleton<AccountMgr>::Instance();
	}

public:
	bool Reg(const std::string& uuid, const std::uint32_t uid, const std::string& agency, const std::string& username, const std::uint32_t agency_id, const std::string& token, const std::string& hall_url, const std::string& platform, const std::int64_t balance, const std::string& currency, const std::string& ext);
	bool Update(const std::string& uuid, const std::uint32_t uid, const std::string& agency, const std::string& username, const std::uint32_t agency_id, const std::string& token, const std::string& hall_url, const std::string& platform, const std::int64_t balance, const std::string& currency, const std::string& ext);
	bool Get(const std::uint32_t uid, std::string& uuid, std::string& agency, std::string& username, std::uint32_t& agency_id, std::string& token, std::string& hall_url, std::string& platform, std::int64_t& balance, std::string& currency, std::string& ext);
	bool Uid(const std::string& uuid, std::uint32_t& uid);
public:
	bool GetUserByUid(const std::uint32_t uid, std::string& uuid, std::string& agency, std::string& username, std::uint32_t& agency_id);
	bool GetUserByUuid(const std::string& uuid, std::uint32_t& uid, std::string& agency, std::string& username, std::uint32_t& agency_id);
public:
	static std::string Uuid(const std::string& agency, const std::string& username);

private:
	ExpireMgr<std::uint32_t, stAccount, 5*3600> m_uid_mgr;  //用户信息缓存5小时
	ExpireMgr<std::string, stAccount, 5*3600> m_uuid_mgr;  //用户信息缓存5小时
};












